Skip to content

v0.60.21.0 fix(persistence): SIGTERM a stopped git child before SIGKILL so it can release index.lock - #5793

Merged
capy-ai[bot] merged 3 commits into
masterfrom
fix/bounded-exec-sigterm-grace
Oct 1, 2026
Merged

capy-ai[bot] merged 3 commits into
masterfrom
fix/bounded-exec-sigterm-grace

Conversation

@garrytan

@garrytan garrytan commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

This fixes a regression in v0.60.16.0 (#5787). execFileBounded stopped a child at its deadline, or on abort, with SIGKILL. Before #5787, execFile sent SIGTERM. When PersistenceConsumer.stop() aborts the effects signal during a git add or git commit, a SIGKILLed git leaves .git/index.lock behind. Every later git call in that worktree then exits 128, which surfaces as git_unavailable and counts toward parking. GBRA-25 found it through fix wave 4's w5-persistence-postgres "a healthy scan and contention never park" failure.

Fix.

  • On a deadline or abort, execFileBounded sends SIGTERM and settles as soon as the child has exited.
  • Because Bun 1.3.x can lose the exit event (process: drop EPOLLONESHOT for Linux pidfd exit poll oven-sh/bun#30301), on Linux it also polls /proc/<pid>/stat every 25 ms and treats a zombie as exited.
  • A child that ignores SIGTERM gets SIGKILL after a 2 s grace period, and the call still settles from its own timer.

Why the zombie check matters. The first version of this PR waited out the full grace period whenever the exit event was lost. That pushed test/e2e/embedding-recovery-parity.test.ts past the 180 s per-file cap on GitHub CI. Local timings on a single Postgres container:

Version embedding-recovery-parity
master 170 s
grace period only 267 s
with zombie check 188 s

All three runs passed all 155 tests.

Tests. test/bounded-child-exec.test.ts gains two cases. In one, a child holding a lock file removes it on SIGTERM; on the old code the lock is left behind. In the other, a child that ignores SIGTERM is still stopped within the bound. The existing lost-event, exit-code, abort and deadline cases pass. persistence-effect-parking, persistence-effect-retry*, persistence-effects and bun run verify also pass.

Versioned v0.60.21.0 (next free after fix wave 4, v0.60.20.0).

@trunk-io

trunk-io Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

…hen the exit event is lost (Linux zombie check), so the grace period only bounds stubborn children
@capy-ai capy-ai Bot changed the title v0.60.17.1 fix(persistence): SIGTERM a stopped git child before SIGKILL so it can release index.lock v0.60.21.0 fix(persistence): SIGTERM a stopped git child before SIGKILL so it can release index.lock Sep 30, 2026
@capy-ai
capy-ai Bot merged commit 6fe4393 into master Oct 1, 2026
72 checks passed
garrytan added a commit that referenced this pull request Oct 1, 2026
garrytan added a commit that referenced this pull request Oct 1, 2026
harjothkhara added a commit to harjothkhara/gbrain that referenced this pull request Oct 1, 2026
Merges master's SIGTERM-before-SIGKILL git-child fix (garrytan#5793) into this
branch. Non-absorption confirmed: master's diff between 3e60b24..6fe4393
touches only src/core/brain-repo-durability.ts and
test/bounded-child-exec.test.ts, not any file this PR's fix lives in.
Version-lockstep files bumped from 0.60.20.1 to 0.60.21.1; derived
artifacts (template repo, plugin tree) regenerated.

Agent-Id: agent-1ce06382-5a83-4028-99b7-7d86c5e1ed00
harjothkhara added a commit to harjothkhara/gbrain that referenced this pull request Oct 1, 2026
Merges master's SIGTERM-before-SIGKILL git-child fix (garrytan#5793) into this
branch. Non-absorption confirmed: master's diff between 3e60b24..6fe4393
does not touch src/commands/doctor/bootstrap-checks.ts,
src/core/pglite-lock.ts, src/core/bootstrap/uninstall.ts, or the
export-surface goldens. Version-lockstep files bumped from 0.60.20.1 to
0.60.21.1; derived artifacts (template repo, plugin tree) regenerated.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant